package it.canraid.shapefile;

import com.bbn.openmap.dataAccess.shape.DbfTableModel;

public class launch {

	static String path="C:/Users/evitcam/Documents/shape_viewer/comuni2011/";
	static String fileDBF="Comuni_11.dbf";
	static String fileSHP="Comuni_11.shp";
	static String fileSHX="Comuni_11.shx";
	
	
	public static void main(String[] args) {
		EShp Rshp=CLoad.loadShp(path+fileSHP);
		EShx Rshx=CLoad.loadShx(path+fileSHX);
		EDbfComuni2011 Rdbf=CLoad.loadDbf(path+fileDBF);
		
		System.out.println("fileCode:"+Rshp.fileCode);
		System.out.println("fileLenght:"+Rshp.fileLenght+"w ("+(int)(Rshp.fileLenght*2)+"byte)");
		System.out.println("version:"+Rshp.version);
		System.out.println("shapeType:"+Rshp.shapeType);
		System.out.print("Xmin:"); System.out.printf("%f", Rshp.Xmin);System.out.println();
		System.out.print("Ymin:"); System.out.printf("%f", Rshp.Ymin);System.out.println();
		System.out.print("Xmax:"); System.out.printf("%f", Rshp.Xmax);System.out.println();
		System.out.print("Ymax:"); System.out.printf("%f", Rshp.Ymax);System.out.println();
		System.out.print("Zmin:"); System.out.printf("%f", Rshp.Zmin);System.out.println();
		System.out.print("Zmax:"); System.out.printf("%f", Rshp.Zmax);System.out.println();
		System.out.print("Mmin:"); System.out.printf("%f", Rshp.Mmin);System.out.println();
		System.out.print("Mmax:"); System.out.printf("%f", Rshp.Mmax);System.out.println();
		
		System.out.println("SHP: TOTAL RECORD:"+Rshp.records.size());
		System.out.println("SHX: TOTAL RECORD:"+Rshx.offset.length);
		System.out.println("DBF: TOTAL RECORD:"+Rdbf.nameColumn.length+" , "+Rdbf.typeColumn.length+" , "+Rdbf.matrix.size()+" , "+Rdbf.matrix.get(0).size());
		System.out.println("DBF: "+Rdbf.typeColumn[0]+" "+Rdbf.typeColumn[1]+" "+Rdbf.typeColumn[2]+" "+Rdbf.typeColumn[3]+" "+Rdbf.typeColumn[4]+" "
				+Rdbf.typeColumn[5]+" "+Rdbf.typeColumn[6]+" ");
		
		for (int i=0; i<Rdbf.typeColumn.length; i++){
			switch(Rdbf.typeColumn[i]){
			case DbfTableModel.TYPE_AUTOINCREMENT:
				System.out.println("TYPE_AUTOINCREMENT :");
				break;
				
			case DbfTableModel.TYPE_BINARY:
				System.out.println("TYPE_BINARY :");
				break;
				
			case DbfTableModel.TYPE_CHARACTER:
				System.out.println("TYPE_CHARACTER :"+ Rdbf.matrix.get(0).get(i).toString() + " "+ (String)Rdbf.matrix.get(0).get(i));
				break;
				
			case DbfTableModel.TYPE_DATE:
				System.out.println("TYPE_DATE :");
				break;
				
			case DbfTableModel.TYPE_DOUBLE:
				System.out.println("TYPE_DOUBLE :");
				break;
				
			case DbfTableModel.TYPE_FLOAT:
				System.out.println("TYPE_FLOAT :"+ Rdbf.matrix.get(0).get(i).toString() + " "+ (Double)Rdbf.matrix.get(0).get(i));
				break;
				
			case DbfTableModel.TYPE_LOGICAL:
				System.out.println("TYPE_LOGICAL :");
				break;
				
			case DbfTableModel.TYPE_LONG:
				System.out.println("TYPE_LONG :");
				break;
				
			case DbfTableModel.TYPE_MEMO:
				System.out.println("TYPE_MEMO :");
				break;
				
			case DbfTableModel.TYPE_NUMERIC:
				System.out.println("TYPE_NUMERIC :"+ Rdbf.matrix.get(0).get(i).toString() + " "+ (Double)Rdbf.matrix.get(0).get(i));
				break;
				
			case DbfTableModel.TYPE_OLE:
				System.out.println("TYPE_OLE :");
				break;
				
			case DbfTableModel.TYPE_TIMESTAMP:
				System.out.println("TYPE_TIMESTAMP :");
				break;
			
			}
		}
		
		System.out.println(Rdbf.nameColumn[0] +" "+ Rdbf.nameColumn[1] +" "+ Rdbf.nameColumn[2] +" "+ Rdbf.nameColumn[3] +" "+ Rdbf.nameColumn[4] +" "+ Rdbf.nameColumn[5] +" "+ Rdbf.nameColumn[6]);
		for (int i=0; i<Rdbf.matrix.size() && i< 10; i++){
			System.out.println(Rdbf.getRow(i).c_1 +" "+ Rdbf.getRow(i).c_2 +" "+ Rdbf.getRow(i).c_3 +" "+ Rdbf.getRow(i).c_4 +" "+ Rdbf.getRow(i).c_5 +" "+ Rdbf.getRow(i).c_6 +" "+ Rdbf.getRow(i).c_7);
		}

	}

}
